package bean.general;

import java.util.HashMap;

public class Style {
	public static final String TABLE_NAME = "styles";
	////////////////////////////////////////////////////////////
	//Column names
	public static final String ID_COL = "idstyles";
	public static final String NAME_COL = "name";
	public static final String DESC_COL = "description";
	////////////////////////////////////////////////////////////
	//MAIN CSS
	public static final String MAIN_HEADER_COL = "main_header";
	public static final String MAIN_BODY_COL = "main_body";
	public static final String MAIN_PAGE_COL = "main_page";
	public static final String MAIN_CONTAINER_COL = "main_container";
	public static final String MAIN_LEFT_COL = "main_left";
	public static final String MAIN_RIGHT_COL = "main_right";
	public static final String MAIN_BOTTOM_COL = "main_bottom";
	public static final String MAIN_SCREEN_COL = "main_screen";

//	public static final String MENU_COL = "menu";
//	public static final String MENU_BG_COL = "menu_bg";
//	public static final String MENU_LI_COL = "menu_li";
//	public static final String MENU_TOP_LINK_COL = "menu_li";

	////////////////////////////////////////////////////////////
	//PREF CSS
	public static final String PREF_TABLE_COL = "pref_table";
	public static final String PREF_TD_ODD_COL = "pref_td_odd";
	public static final String PREF_TD_EVEN_COL = "pref_td_even";
	public static final String PREF_TH_COL = "pref_th";
	////////////////////////////////////////////////////////////
	
	////////////////////////////////////////////////////////////
	//Bean fields
	private String id;
	private String name;
	private String description;
	private String mainHeader;
	private String mainBody;
	private String mainPage;
	private String mainContainer;
	private String mainLeft;
	private String mainRight;
	private String mainBottom;
	private String mainScreen;
	private String prefTable;
	private String prefTdOdd;
	private String prefTdEven;
	private String prefTh;
	////////////////////////////////////////////////////////////
	
	/**
	 * Get the info from a table ROW by column name
	 * @param line
	 */
	public Style(HashMap<String, String> line) {
		id = line.get(ID_COL);
		name = line.get(NAME_COL);
		description = line.get(DESC_COL);
		mainHeader = line.get(MAIN_HEADER_COL);
		mainBody = line.get(MAIN_BODY_COL);
		mainPage = line.get(MAIN_PAGE_COL);
		mainContainer = line.get(MAIN_CONTAINER_COL);
		mainLeft = line.get(MAIN_LEFT_COL);
		mainRight = line.get(MAIN_RIGHT_COL);
		mainBottom = line.get(MAIN_BOTTOM_COL);
		mainScreen = line.get(MAIN_SCREEN_COL);
		prefTable = line.get(PREF_TABLE_COL);
		prefTdOdd = line.get(PREF_TD_ODD_COL);
		prefTdEven = line.get(PREF_TD_EVEN_COL);
		prefTh = line.get(PREF_TH_COL);
	}
	
	public String cssFormat(String input){
		StringBuilder output = new StringBuilder();
		
		char c;
		for (int i = 0; i < input.length(); i++)
		{
			c = input.charAt(i);
			if (c == '{' || c == ';')
			{
				output.append(c);
				output.append("\n\t");
			}
			else if (c == '}')
			{
				output.deleteCharAt(output.length() - 1);
				output.append(c);
			}
			else
			{
				output.append(c);
			}
		}
		
		return output.toString();
	}

	////////////////////////////////////////////////////////////
	//Getters and setters
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getMainHeader() {
		return cssFormat(mainHeader);
	}
	public void setMainHeader(String mainHeader) {
		this.mainHeader = mainHeader;
	}
	public String getMainBody() {
		return cssFormat(mainBody);
	}
	public void setMainBody(String mainBody) {
		this.mainBody = mainBody;
	}
	public String getMainPage() {
		return cssFormat(mainPage);
	}
	public void setMainPage(String mainPage) {
		this.mainPage = mainPage;
	}
	public String getMainContainer() {
		return cssFormat(mainContainer);
	}
	public void setMainContainer(String mainContainer) {
		this.mainContainer = mainContainer;
	}
	public String getMainLeft() {
		return cssFormat(mainLeft);
	}
	public void setMainLeft(String mainLeft) {
		this.mainLeft = mainLeft;
	}
	public String getMainRight() {
		return cssFormat(mainRight);
	}
	public void setMainRight(String mainRight) {
		this.mainRight = mainRight;
	}
	public String getMainBottom() {
		return cssFormat(mainBottom);
	}
	public void setMainBottom(String mainBottom) {
		this.mainBottom = mainBottom;
	}
	public String getMainScreen() {
		return cssFormat(mainScreen);
	}
	public void setMainScreen(String mainScreen) {
		this.mainScreen = mainScreen;
	}
	public String getPrefTable() {
		return cssFormat(prefTable);
	}
	public void setPrefTable(String prefTable) {
		this.prefTable = prefTable;
	}
	public String getPrefTdOdd() {
		return cssFormat(prefTdOdd);
	}
	public void setPrefTdOdd(String prefTdOdd) {
		this.prefTdOdd = prefTdOdd;
	}
	public String getPrefTdEven() {
		return cssFormat(prefTdEven);
	}
	public void setPrefTdEven(String prefTdEven) {
		this.prefTdEven = prefTdEven;
	}
	public String getPrefTh() {
		return cssFormat(prefTh);
	}
	public void setPrefTh(String prefTh) {
		this.prefTh = prefTh;
	}
	////////////////////////////////////////////////////////////
}
